import { useEffect } from "react";
import { useNavigate } from "react-router-dom";

import useSecurity  from "../hooks/useSecurity";

export default function SecurityRoute({ children }) {
  const { loggedIn } = useSecurity();
  const navigate = useNavigate();

  useEffect(() => {
    if (!loggedIn) {
      navigate("/403", { replace: true });
    }
  }, [navigate, loggedIn]);

  return children;
}
